
<?php include './application/views/common/header.php'; ?>
<table width="90%" cellspacing="0" cellpadding="0" border="0" class="user_table" style="width:1000px;margin:50px auto;">
	<tr>
		<td valign="top" class="user_table_td"><?php include './application/views/common/user_left.php'; ?></td>
		<!-- Left End -->
		<td valign="top">

<div class="user_list_title">
  <?php include './application/views/common/user_sub_left.php'; ?>
</div>
<!-- User_List_Title End -->

<div class="user_list_con">
		<div class="user_right_border">
			<p><?php echo isset($user['username']) ? $user['username'] : '';?> 您好！</p>
		</div>

<form id="my_form">
<input type="hidden" name="act" value="set">
		<div class="user_right_border">
			<div class="l">设置交易密码：</div>
			<div class="c">
                            <input class="input" type="password" maxlength="20" name="paypwd1" id="paypwd1">
			</div>
		</div>

		<div class="user_right_border">
			<div class="l">重复交易密码：</div>
			<div class="c">
				<input class="input" type="password" maxlength="20" name="paypwd2" id="paypwd2">
			</div>
		</div>

		<div class="user_right_border">
			<div class="l"></div>
			<div class="c">
			<input class="little_button" type="button" size="30" value="确认提交" onclick="toSubmit();">
			</div>
		</div>
</form>
<script>
<?php if($msg!=''){?>
$(function(){
	$('#dialog').dialog({
		modal:true,
		title:'系统提示',
		buttons:{"确定":function(){$(this).dialog("close");}},
		close: function() {
			location="<?php echo $url;?>";
		}
	});
	$("#msg").html("<?php echo $msg;?>");
});

<?php }?>

function toSubmit(){
	var options = {
		url : window.location.href,
		clearForm :true,
		resetForm :true,
		beforeSubmit:  checkForm,
		dataType: "json",
		type:"post",
		success : function(ret) {
			if(ret.msg==''){
				$('#dialog').dialog({
					modal:true,
					title:'系统提示',
					buttons:{"确定":function(){$(this).dialog("close");}},
					close: function() {
						location=ret.url;
					}
				});
				$("#msg").html("操作成功");
			}else{
				$('#dialog').dialog({
					modal:true,
					title:'系统提示',
					buttons:{"确定":function(){$(this).dialog("close");}}
				});
				$("#msg").html(ret.msg);
			}
		}
	};
	$("#my_form").ajaxSubmit(options);
	return false;
}

function checkForm(){
	var err = '';
	if($('#paypwd1').val()==''){
		err = '请输入交易密码';
	}else if($('#paypwd2').val()==''){
		err = '请重复交易密码';
	}else if($('#paypwd1').val()!=$('#paypwd2').val()){
		err = '两次密码输入不一致';
	}

	if(err==''){
		return true;
	}else{
		$('#dialog').dialog({
			modal:true, //蒙层（弹出会影响页面大小）
			title:'系统提示',
			buttons:{"确定":function(){$(this).dialog("close");}},
			close: function() {
				$("#my_form").resetForm();
			}
		});
		$("#msg").html(err);
		return false;
	}
}
</script>
</div>
<!-- User_List_Con End -->
</td>
	</tr>
</table>

<?php include './application/views/common/footer.php'; ?>